﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
Copyright 2010 Mirosław M. Mączka

This file is part of Mp3Cleaner.

    Mp3Cleaner is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
namespace Mp3Edit
{
    public class WaitingTooLong
    {
        private DateTime dt = DateTime.MinValue;
        private TimeSpan ts = TimeSpan.Zero;
        //
        public WaitingTooLong(int seconds)
        {
            this.ts = TimeSpan.FromSeconds((double)seconds);
            this.dt = DateTime.Now;
        }
        public void Start(int seconds)
        {
            this.ts = TimeSpan.FromSeconds((double)seconds);
            this.dt = DateTime.Now;
        }
        public bool isTooLong()
        {
            return (dt + ts) < DateTime.Now;
        }
        public bool isTooLongBeep(IntPtr hWnd)
        {
            if (isTooLong())
            {
                if (IntPtr.Zero != hWnd)
                {
                    FlashWindow.FlashWindow.Blink(hWnd, 2);
                }
                System.Media.SystemSounds.Beep.Play();
                return true;
            }
            return false;
        }
    }//class
}
